package org.ttitfly.workflow.engine.decider;

import org.ttitfly.workflow.SessionHolder;
import org.ttitfly.workflow.engine.run.Task;


/**
 * 默认权限决策，只要当前用户拥有该任务即许可
 * 
 * @author 潘海春
 * @version 2009-9-18
 */
public class DefaultPermissionDecider implements Decider {

	@Override
	public boolean decide() {
		Task task = SessionHolder.currentSession().currentTask();
		String assigners = task.getAssigners();
		if (assigners == null || "".equals(assigners)) {
			return true;
		}
		String principal = SessionHolder.currentSession().getPrincipal();
		if (principal == null || "".equals(principal)) {
			return false;
		}
		return ("," + assigners + ",").indexOf("," + principal + ",") >= 0;
	}

}
